import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'landing-page',
      component: require('@/view/home').default
    },
    {
      path: '/seach/:musicName',
      name: 'seach',
      props: true,
      component: require('@/components/seachList').default
    },
    {
      path: '/list/:rankid',
      name: 'list',
      component: require('@/components/list').default
    },
    {
      path: '/topList',
      name: 'topList',
      component: require('@/view/topList').default
    },
    {
      path: '/ranking',
      name: 'ranking',
      component: require('@/view/ranking').default
    },
    {
      path: '*',
      redirect: '/'
    }
  ]
})

const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
